package us.gaaoc.framework.webapp.backingbeans.admin;


import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.component.UIParameter;
import javax.faces.component.UISelectItem;
import javax.faces.component.html.HtmlSelectOneListbox;
import javax.faces.context.FacesContext;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.faces.model.SelectItem;
import javax.faces.validator.ValidatorException;

import us.gaaoc.framework.businessmodel.Filing;
import us.gaaoc.framework.model.CaseRecord;
import us.gaaoc.framework.model.OrgParticipants;
import us.gaaoc.framework.model.Person;
import us.gaaoc.framework.model.PersonParticipants;
import us.gaaoc.framework.model.util.DataPage;
import us.gaaoc.framework.model.util.FilingSorter;
import us.gaaoc.framework.model.util.PagedListDataModel;
import us.gaaoc.framework.webapp.backingbeans.BaseBackingBean;
import us.gaaoc.framework.webapp.backingbeans.caseTypes.StatusType;
import us.gaaoc.framework.webapp.backingbeans.profile.Links;
import us.gaaoc.framework.webapp.util.Messages;

/**
 * 
 * @author hea
 * @date Apr 26, 2006
 * @version: GAJE 1.5
 * 
 */
public class ChildEnforcementCaseType extends BaseBackingBean {

	
	/**
	 * Property
	 */
	private UIParameter clickedClear;

	private HtmlSelectOneListbox statusUI;

	private StatusType status;

	private Filing filing;

	private DataModel childEnforcementFilingTableList;
	
	private DataModel readyToImportFilingTableList;
	
	private DataModel childEnforcementClearedFilingsTableList;
	                  
	private String docketID;

	private UIInput docketIDInput;
	private UIParameter caseDetailsPageClicked;
	private UIParameter caseDetailsPageClicked_RTI;
	private UIParameter caseDetailsPageClicked_Cleared;
	private UIParameter restoreClicked;

	private FacesMessage message;

	private boolean showMessage;

	private String noDetailsMessage;
	
	private List<Filing> childEnforcementFilings;
	private List<Filing> readyToImportFilings;
	private List<Filing> childEnforcementClearedFilings;
	
	//Variables Used for Sort functionality
	private FilingSorter filingSorter;
	private FilingSorter filingSorter_RTI;
	private FilingSorter filingSorter_Cleared;
		
	// Variables Used for Paging ChildEnforcement Filings
	private int childEnforcementRowCount;
	private int readyToImportRowCount;
	private int childEnforcementClearedFilingsRowCount;
	
	//private String formReceivedCaseRecordUuid;
	//private List<PersonParticipants> caseRecordParticipants = new ArrayList<PersonParticipants>();
	
	//private DataModel initiatingPartyPersonModel;
	//private DataModel defendentPartyPersonModel;
	//private DataModel witnessPersonModel;
	//private DataModel plaintiffsAttorneyModel;
	//private DataModel defendentsAttorneyModel;
	//private String filerName;
	
	private String courtUuid;
	


	/**
	 * Constructor
	 *
	 */
	@SuppressWarnings("unchecked")
	public ChildEnforcementCaseType() {
		this.statusUI = new HtmlSelectOneListbox();
		this.status = new StatusType();
		for (Links links : this.status.getMenu()) {
			SelectItem item = new SelectItem(links.getNavigationRule(), links
					.getText());
			UISelectItem uiItem = new UISelectItem();
			uiItem.setValue(item);
			this.statusUI.getChildren().add(uiItem);
		}
		
		filingSorter = new FilingSorter("eventDateTime",this.getChildEnforcementFilings());
		filingSorter_RTI = new FilingSorter("eventDateTime",this.getReadyToImportFilings());
		filingSorter_Cleared = new FilingSorter("eventDateTime",this.getChildEnforcementClearedFilings());

		// type = childEnforcementCase (1)
		//List caseRecordList = this.getModelFacade().findCaseFilingsByType(1);
		//List caseRecordList = this.getModelFacade().findAllFilingsByTypeForClerk(1);
		//childEnforcementFilingTableList = new ListDataModel();
		//childEnforcementFilingTableList.setWrappedData(caseRecordList);

		Map sessionMap = this.getFacesContext().getExternalContext()
				.getSessionMap();
		courtUuid = (String)sessionMap.get("courtUuid");
		String message = (String) sessionMap.get("showMessage");
		if (message != null) {
			sessionMap.remove("showMessage");
			this.setShowMessage(true);
			this.setNoDetailsMessage(message);
		}
		//this.getParticipants();
		//sessionMap.put("from", "ChildEnforcementCaseDetailsPage");
	}

	/**
	 * Getter for property clickedClear
	 * @return clickedClear
	 */
	public UIParameter getClickedClear() {
		return clickedClear;
	}

	/**
	 * Setter for property clickedClear
	 * @param clickedClear
	 */
	public void setClickedClear(UIParameter clickedClear) {
		this.clickedClear = clickedClear;
	}

	/**
	 * Getter for property statusUI
	 * @return statusUI
	 */
	public HtmlSelectOneListbox getStatusUI() {
		return statusUI;
	}

	/**
	 * Setter for property statusUI
	 * @param statusUI
	 */
	public void setStatusUI(HtmlSelectOneListbox statusUI) {
		this.statusUI = statusUI;
	}

	/**
	 * Getter for property filing
	 * @return filing
	 */
	public Filing getFiling() {
		return filing;
	}

	/**
	 * Setter for property filing
	 * @param filing
	 */
	public void setFiling(Filing filing) {
		this.filing = filing;
	}

	/**
	 * Getter for property childEnforcementFilingTableList
	 * @return childEnforcementFilingTableList
	 */
	public DataModel getChildEnforcementFilingTableList() {
		childEnforcementFilingTableList = new ChildEnforcementFilingsDataModel(10);
		return childEnforcementFilingTableList;
	}

	/**
	 * Getter for property docketID
	 * @return
	 */
	public String getDocketID() {
		return docketID;
	}

	/**
	 * Setter for property docketID
	 * @param docketID
	 */
	public void setDocketID(String docketID) {
		this.docketID = docketID;
	}

	/**
	 * Getter for property docketIDInput
	 * @return docketIDInput
	 */
	public UIInput getDocketIDInput() {
		return docketIDInput;
	}

	/**
	 * Setter for property docketIDInput
	 * @param docketIDInput
	 */
	public void setDocketIDInput(UIInput docketIDInput) {
		this.docketIDInput = docketIDInput;
	}

	/**
	 * Getter for property showMessage
	 * @return showMessage
	 */
	public boolean isShowMessage() {
		return showMessage;
	}
	
	/**
	 * Setter for property showMessage
	 * @param showMessage
	 */
	public void setShowMessage(boolean showMessage) {
		this.showMessage = showMessage;
	}
	
	/**
	 * Getter for property noDetailsMessage
	 * @return noDetailsMessage
	 */
	public String getNoDetailsMessage() {
		return noDetailsMessage;
	}

	/**
	 * Setter for property noDetailsMesage
	 * @param noDetailsMessage
	 */
	public void setNoDetailsMessage(String noDetailsMessage) {
		this.noDetailsMessage = noDetailsMessage;
	}

	/**
	 * @return the childEnforcementFilings
	 */
	public List<Filing> getChildEnforcementFilings() {
		return childEnforcementFilings;
	}

	/**
	 * @param childEnforcementFilings the childEnforcementFilings to set
	 */
	public void setChildEnforcementFilings(List<Filing> childEnforcementFilings) {
		this.childEnforcementFilings = childEnforcementFilings;
	}

	/**
	 * @return the childEnforcementRowCount
	 */
	public int getChildEnforcementRowCount() {
		childEnforcementRowCount = this.getModelFacade().findNumberOfCaseFilingsByTypeForAdmin(1, courtUuid);
		return childEnforcementRowCount;
	}

	/**
	 * @param childEnforcementRowCount the childEnforcementRowCount to set
	 */
	public void setChildEnforcementRowCount(int childEnforcementRowCount) {
		this.childEnforcementRowCount = childEnforcementRowCount;
	}

	/**
	 * @return the filingSorter
	 */
	public FilingSorter getFilingSorter() {
		return filingSorter;
	}

	/**
	 * @param filingSorter the filingSorter to set
	 */
	public void setFilingSorter(FilingSorter filingSorter) {
		this.filingSorter = filingSorter;
	}

	/**
	 * @return the filingSorter_RTI
	 */
	public FilingSorter getFilingSorter_RTI() {
		return filingSorter_RTI;
	}

	/**
	 * @param filingSorter_RTI the filingSorter_RTI to set
	 */
	public void setFilingSorter_RTI(FilingSorter filingSorter_RTI) {
		this.filingSorter_RTI = filingSorter_RTI;
	}

	/**
	 * @return the readyToImportFilings
	 */
	public List<Filing> getReadyToImportFilings() {
		return readyToImportFilings;
	}

	/**
	 * @param readyToImportFilings the readyToImportFilings to set
	 */
	public void setReadyToImportFilings(List<Filing> readyToImportFilings) {
		this.readyToImportFilings = readyToImportFilings;
	}

	/**
	 * @return the readyToImportFilingTableList
	 */
	public DataModel getReadyToImportFilingTableList() {
		readyToImportFilingTableList = new ReadyToImportFilingsDataModel(10);
		return readyToImportFilingTableList;
	}

	/**
	 * @param readyToImportFilingTableList the readyToImportFilingTableList to set
	 */
	public void setReadyToImportFilingTableList(
			DataModel readyToImportFilingTableList) {
		this.readyToImportFilingTableList = readyToImportFilingTableList;
	}
	
	
	/**
	 * @return the childEnforcementClearedFilingsTableList
	 */
	public DataModel getChildEnforcementClearedFilingsTableList() {
		childEnforcementClearedFilingsTableList = new ChildEnforcementClearedFilingsDataModel(10);
		return childEnforcementClearedFilingsTableList;
	}

	/**
	 * @param childEnforcementClearedFilingsTableList the childEnforcementClearedFilingsTableList to set
	 */
	public void setChildEnforcementClearedFilingsTableList(
			DataModel childEnforcementClearedFilingsTableList) {
		this.childEnforcementClearedFilingsTableList = childEnforcementClearedFilingsTableList;
	}
	
	
	
	

	/**
	 * @return the readyToImportRowCount
	 */
	public int getReadyToImportRowCount() {
		System.out.println("Cetting the number of cases ready to be imported");
		readyToImportRowCount = this.getModelFacade().findNumberOfCaseFilingsByTypeAndStatus(1, 20, courtUuid);
		System.out.println("The number of cases ready to be imported is "+readyToImportRowCount);
		return readyToImportRowCount;
	}

	/**
	 * @param readyToImportRowCount the readyToImportRowCount to set
	 */
	public void setReadyToImportRowCount(int readyToImportRowCount) {
		this.readyToImportRowCount = readyToImportRowCount;
	}

	/**
	 * This method navigates user to the Case Details Page
	 * @return String
	 */
	/*@SuppressWarnings("unchecked")
	public String gotoCaseDetailPage() {
		Map sessionMap = this.getFacesContext().getExternalContext()
				.getSessionMap();
		Map requestMap = this.getFacesContext().getExternalContext()
				.getRequestParameterMap();
		String caseUuid = ((String) requestMap.get("caseUuid"));
		sessionMap.put("caseUuid", caseUuid);
		sessionMap.put("from", "ChildEnforcementCaseTypePage");
		return "gotoCaseDetailsPage";
	}*/
	public String gotoCaseDetailPage(){
		Map sessionMap = this.getFacesContext().getExternalContext().getSessionMap();
	 	Filing tempFiling1 = (Filing)this.getCaseDetailsPageClicked().getValue();
	 	Filing tempFiling2 = (Filing)this.getCaseDetailsPageClicked_RTI().getValue();
	 	Filing tempClearedFiling = (Filing)this.getCaseDetailsPageClicked_Cleared().getValue();
	 	if (tempFiling1 != null)  {
	 		this.setFiling(tempFiling1);
	 	} else if (tempFiling2 != null) {
	 		this.setFiling(tempFiling2);
	 	} else if(tempClearedFiling !=null){
	 		this.setFiling(tempClearedFiling);
	 	}
	 	
	 	//this.setFiling ( (Filing)this.getCaseDetailsPageClicked().getValue());
	 	String caseType = filing.getCaseType();
	 
	 	
	 	sessionMap.put("caseUuid", filing.getUuid());
	 	sessionMap.put("from", "ChildEnforcementCaseTypePage");
	 	return "gotoCSECaseDetailsPage";
	}
	
	public String RestoreToNotCleared(){
		Map sessionMap = this.getFacesContext().getExternalContext().getSessionMap();
	 	Filing tempClearedFiling = (Filing)this.getRestoreClicked().getValue();
		String caseRecordUuid = tempClearedFiling.getUuid();
		//String caseRecordUuid = (String)this.getRestoreClicked().getValue();
		this.getModelFacade().UpdateFilingByClearFilingFlag(1, caseRecordUuid, false, courtUuid);
	 	this.setFiling(tempClearedFiling);
	 	String caseType = filing.getCaseType();	 
	 	sessionMap.put("caseUuid", filing.getUuid());
	 	sessionMap.put("from", "MainPage");
	 	//return "gotoCSECaseDetailsPage";
	 	return "stay";
	}
	
	/**
	 * @return Returns the caseDetailsPageClicked.
	 */
	public UIParameter getCaseDetailsPageClicked() {
		return caseDetailsPageClicked;
	}

	/**
	 * @param caseDetailsPageClicked The caseDetailsPageClicked to set.
	 */
	public void setCaseDetailsPageClicked(UIParameter caseDetailsPageClicked) {
		this.caseDetailsPageClicked = caseDetailsPageClicked;
	}
	
	/**
	 * @return the caseDetailsPageClicked_RTI
	 */
	public UIParameter getCaseDetailsPageClicked_RTI() {
		return caseDetailsPageClicked_RTI;
	}

	/**
	 * @param caseDetailsPageClicked_RTI the caseDetailsPageClicked_RTI to set
	 */
	public void setCaseDetailsPageClicked_RTI(UIParameter caseDetailsPageClicked_RTI) {
		this.caseDetailsPageClicked_RTI = caseDetailsPageClicked_RTI;
	}

	/**
	 * This method navigates user to the corresponding page depending on the status
	 * @return String
	 */
	public String submitStatus() {
		String navigationString = "";
		if (this.getStatusUI().getValue().equals("received"))
			navigationString = "received";
		else if (this.getStatusUI().getValue().equals("imported"))
			navigationString = "imported";
		else if (this.getStatusUI().getValue().equals("queued"))
			navigationString = "queued";
		else if (this.getStatusUI().getValue().equals("rejected"))
			navigationString = "rejected";
		else if (this.getStatusUI().getValue().equals("served"))
			navigationString = "served";
		else if (this.getStatusUI().getValue().equals("non-served"))
			navigationString = "non-served";
		else if (this.getStatusUI().getValue().equals("disposed"))
			navigationString = "disposed";
		else if (this.getStatusUI().getValue().equals("negotiate"))
			navigationString = "negotiate";
		return navigationString;
	}

	/**
	 * This method navigates user to the previous page
	 * @return String
	 */
	public String back() {
		return "back";
	}
	
	/**
	 *  This method navigates the user to the search page
	 * @return
	 */
	public String gotoSearchPage() {
		Map sessionMap = this.getFacesContext().getExternalContext().getSessionMap();
	 	sessionMap.put("from", "adminChildEnforcementCaseTypePage");
		return "gotoSearchPage";
		//return "back";
	}
	
	
	
	

	/**
	 * This method clears the case record from the list and puts in the trash can
	 * @return String
	 */
	public String clearRecord() {
		this.filing = (Filing) this.getClickedClear().getValue();
		this.getModelFacade().updateCaseRecordForClearCase(
				this.getFiling().getUuid(), true, courtUuid);
		//HibernatePhaseListener.getSessionFactory().getCurrentSession()
		//		.getTransaction().commit();
		return "stay";
	}

	/**
	 * This method navigates user to the Trash Can Page
	 * @return String
	 */
	@SuppressWarnings("unchecked")
	public String trashcan() {
		Map sessionMap =this.getFacesContext().getExternalContext()
				.getSessionMap();
		sessionMap.put("from2", "childEnforcement");
		return "trashcan";
	}

	/**
	 * This method search for the case record corresponding the docketID and 
	 * navigates the user to the Case Details Page
	 * @return String
	 */
	@SuppressWarnings("unchecked")
	@Deprecated
	public String findCaseDetailsByDocketID() {
		
		throw new UnsupportedOperationException("findCaseDetailsByDocketID is disabled");
		
		/*
		Map sessionMap = this.getFacesContext().getExternalContext()
		.getSessionMap();
		CaseRecord c = this.getModelFacade().findCaseRecordByDocketID(
				this.getDocketID().trim(), courtUuid);
		
		if (c != null) {
			sessionMap.put("caseUuid", c.getUuid());
			sessionMap.put("from", "ChildEnforcementCaseTypePage");
			return "gotoCaseDetailsPage";
		} else {
			sessionMap.put("showMessage",
					"There is no case details found by the given docketID "
							+ this.getDocketID() + ".");
			return "stay";
		}
		*/
	}

	/**
	 * This method validates docketID entered by user
	 * @param context
	 * @param component
	 * @param value
	 * @throws ValidatorException
	 * @throws Exception
	 */
	public void validateDocketID(FacesContext context, UIComponent component,
			Object value) throws ValidatorException, Exception {
		String docketID = (String) value;
		if (!isValidDocketID(docketID.trim())) {
			message.setSeverity(FacesMessage.SEVERITY_ERROR);
			throw new ValidatorException(message);
		}
	}

	/**
	 * Helper method to validate the docketID entered by user
	 * @param docketID
	 * @return boolean
	 * @throws Exception
	 */
	protected boolean isValidDocketID(String docketID) throws Exception {
		boolean validField = false;
		char[] charArray = docketID.toCharArray();
		if (!(charArray.length > 10 || charArray.length < 9)) {
			for (char c : charArray) {
				if (!(Character.isDigit(c) || Character.isLetter(c))) {
					message = Messages.getMessage(
							"us.gaaoc.framework.webapp.util.errorMessage",
							"incorrectDocketID", new Object[] { docketID });
					message.setDetail(message.getDetail());
					message.setSeverity(FacesMessage.SEVERITY_ERROR);
					validField = false;
					break;
				} else
					validField = true;
			}
		} else {
			message = Messages.getMessage(
					"us.gaaoc.framework.webapp.util.errorMessage",
					"incorrectDocketID", new Object[] { docketID });
			message.setDetail(message.getDetail());
			message.setSeverity(FacesMessage.SEVERITY_ERROR);
		}
		return validField;
	}

	/**
	 * This method resets the input field for docketID 
	 * @return String
	 */
	public String reset() {
		this.setDocketID("");
		return "stay";
	}

	/**
	 * This method navigates user to the Case Record History Page
	 * @return String
	 */
	@SuppressWarnings("unchecked")
	public String gotoHistoryPage() {
		Map sessionMap = this.getFacesContext().getExternalContext()
				.getSessionMap();
		Map requestMap = this.getFacesContext().getExternalContext()
				.getRequestParameterMap();
		String caseUuid = ((String) requestMap.get("caseUuid"));
		sessionMap.put("caseUuid", caseUuid);
		sessionMap.put("from", "ChildEnforcementCaseTypePage");
		return "gotoCaseHistoryPage";
	}
	
	/**
	 * Method used for paging of large data set with Data Page class
	 */
	private DataPage<Filing> getChildEnforcementClearedFilingsDataPage(int startRow, int pageSize){
        int dataSetSize = getChildEnforcementClearedFilingsRowCount();
        System.out.println("The number of cleared cases is "+dataSetSize);
		if(dataSetSize  >= 10) {
			//System.out.println("The data set size is "+dataSetSize);
			List<Filing> ceClearedFilings = this.getModelFacade().findAllClearedFilings(1, courtUuid);
			DataPage<Filing> adminSideClearedFilingsDataTableList = new DataPage<Filing>(dataSetSize, startRow, ceClearedFilings);
			filingSorter_Cleared.sort("eventDateTime", filingSorter_Cleared.isAscending(),ceClearedFilings);
			return adminSideClearedFilingsDataTableList;
		}
		else {
			//System.out.println("Inside the last data set. The data set size is "+dataSetSize);
			List<Filing> ceClearedFilings = this.getModelFacade().findAllClearedFilings(1, courtUuid);
			DataPage<Filing> adminSideClearedFilingsDataTableList = new DataPage<Filing>(dataSetSize, startRow, ceClearedFilings);
			filingSorter_Cleared.sort("eventDateTime", filingSorter_Cleared.isAscending(),ceClearedFilings);
			return adminSideClearedFilingsDataTableList;
		}
	}
	
	
	/**
	 * Method used for paging of large data set with Data Page class
	 */
	private DataPage<Filing> getChildEnforcementFilingsDataPage(int startRow, int pageSize){
		
        int dataSetSize = getChildEnforcementRowCount();
		//int dataSetSize = this.getModelFacade().findNumberOfCaseFilingsByTypeAndStatus(1, 1, 1, 14, 14);
		if(dataSetSize  >= 10) {
			List<Filing> ceFilings = this.getModelFacade().findAllFilingsByTypeForClerkPaged(1, startRow, pageSize, courtUuid);
			//List<Filing> ceFilings = this.getModelFacade().findCaseFilingsByTypeAndStatusPaged(1, 1, 1, 14, 14, startRow, pageSize);
			DataPage<Filing> courtSideImportedDataTableListForPage = new DataPage<Filing>(dataSetSize, startRow, ceFilings);
			filingSorter.sort("eventDateTime", filingSorter.isAscending(),ceFilings);
			return courtSideImportedDataTableListForPage;
		}
		else {
			//List<Filing> ceFilings = this.getModelFacade().findAllFilingsByTypeForClerk(1);
			List<Filing> ceFilings = this.getModelFacade().findAllFilingsByTypeForAdmin(1, courtUuid);
			DataPage<Filing> courtSideImportedDataTableListForPage = new DataPage<Filing>(dataSetSize, startRow, ceFilings);
			filingSorter.sort("eventDateTime", filingSorter.isAscending(),ceFilings);
			return courtSideImportedDataTableListForPage;
		}
	}
	
	/**
	 * Method used for paging of large data set with Data Page class
	 */
	private DataPage<Filing> getReadyToImportFilingsDataPage(int startRow, int pageSize){
		System.out.println("Inside the getReadyToImportFilingsDataPage method ");
        int dataSetSize = getReadyToImportRowCount();
        System.out.println("The number of cases ready to be imported is "+dataSetSize);
		if(dataSetSize  >= 10) {
			List<Filing> rtiFilings = this.getModelFacade().findCaseFilingsByTypeAndStatusPaged(1, 20, startRow, pageSize, courtUuid);
			DataPage<Filing> readyToImportDataTableListForPage = new DataPage<Filing>(dataSetSize, startRow, rtiFilings);
			filingSorter_RTI.sort("eventDateTime", filingSorter_RTI.isAscending(),rtiFilings);
			return readyToImportDataTableListForPage;
		}
		else {
			List<Filing> rtiFilings = this.getModelFacade().findCaseFilingsByTypeAndStatus(1,20, courtUuid);
			DataPage<Filing> readyToImportDataTableListForPage = new DataPage<Filing>(dataSetSize, startRow, rtiFilings);
			filingSorter_RTI.sort("eventDateTime", filingSorter_RTI.isAscending(),rtiFilings);
			return readyToImportDataTableListForPage;
		}
	}
	
	/**
	 * Internal Class used for paging of New Filings Data
	 * 
	 * @author mcelratr
	 *
	 */
	private class ChildEnforcementFilingsDataModel extends PagedListDataModel {
		public ChildEnforcementFilingsDataModel(int pageSize) {
            super(pageSize);
        }
        
        public DataPage<Filing> fetchPage(int startRow, int pageSize) {
            // call enclosing managed bean method to fetch the data
        	return ChildEnforcementCaseType.this.getChildEnforcementFilingsDataPage(startRow, pageSize);
        }
    }
	
	/**
	 * Internal Class used for paging of ReadyToImport Status Filings Data
	 * 
	 * @author mcelratr
	 *
	 */
	private class ReadyToImportFilingsDataModel extends PagedListDataModel {
		public ReadyToImportFilingsDataModel(int pageSize) {
            super(pageSize);
        }
        
        public DataPage<Filing> fetchPage(int startRow, int pageSize) {
            // call enclosing managed bean method to fetch the data
        	return ChildEnforcementCaseType.this.getReadyToImportFilingsDataPage(startRow, pageSize);
        }
    }
	
	
	/**
	 * Internal Class used for paging of Child Enforcement Cleared Filings Data
	 * 
	 */
	private class ChildEnforcementClearedFilingsDataModel extends PagedListDataModel {
		public ChildEnforcementClearedFilingsDataModel(int pageSize) {
            super(pageSize);
        }
        
        public DataPage<Filing> fetchPage(int startRow, int pageSize) {
            // call enclosing managed bean method to fetch the data
        	return ChildEnforcementCaseType.this.getChildEnforcementClearedFilingsDataPage(startRow, pageSize);
        }
    }
	

	public FilingSorter getFilingSorter_Cleared() {
		return filingSorter_Cleared;
	}

	public void setFilingSorter_Cleared(FilingSorter filingSorter_Cleared) {
		this.filingSorter_Cleared = filingSorter_Cleared;
	}

	public int getChildEnforcementClearedFilingsRowCount() {
		childEnforcementClearedFilingsRowCount = this.getModelFacade().findNumberOfClearedFilingsByType(1, courtUuid);
		System.out.println("The row count of cleared filings is "+childEnforcementClearedFilingsRowCount);
		return childEnforcementClearedFilingsRowCount;
	}

	public void setChildEnforcementClearedFilingsRowCount(
			int childEnforcementClearedFilingsRowCount) {
		this.childEnforcementClearedFilingsRowCount = childEnforcementClearedFilingsRowCount;
	}

	public List<Filing> getChildEnforcementClearedFilings() {
		return childEnforcementClearedFilings;
	}

	public void setChildEnforcementClearedFilings(
			List<Filing> childEnforcementClearedFilings) {
		this.childEnforcementClearedFilings = childEnforcementClearedFilings;
	}

	public UIParameter getCaseDetailsPageClicked_Cleared() {
		return caseDetailsPageClicked_Cleared;
	}

	public void setCaseDetailsPageClicked_Cleared(
			UIParameter caseDetailsPageClicked_Cleared) {
		this.caseDetailsPageClicked_Cleared = caseDetailsPageClicked_Cleared;
	}

	public UIParameter getRestoreClicked() {
		return restoreClicked;
	}

	public void setRestoreClicked(UIParameter restoreClicked) {
		this.restoreClicked = restoreClicked;
	}



}